package com.xiaotao.service.impl;

import com.xiaotao.entity.Type;
import com.xiaotao.mapper.TypeMapper;
import com.xiaotao.service.TypeService;
import com.xiaotao.util.ResponseEnum;
import com.xiaotao.util.ResponseUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TypeServiceImpl implements TypeService {
    @Resource
    private TypeMapper typeMapper;
    @Override
    public ResponseUtil findAll() {
        List<Type> list= typeMapper.findAll();
        return list!=null?ResponseUtil.get(ResponseEnum.OK,list):
                ResponseUtil.get(ResponseEnum.FAIL);
    }

    @Override
    public ResponseUtil update(Type type) {
        int i = typeMapper.updateByPrimaryKey(type);
        return i>0?ResponseUtil.get(ResponseEnum.OK):
                ResponseUtil.get(ResponseEnum.FAIL);
    }

    @Override
    public ResponseUtil delete(Integer id) {
        int i = typeMapper.deleteByPrimaryKey(id);
        return i>0?ResponseUtil.get(ResponseEnum.OK):
                ResponseUtil.get(ResponseEnum.FAIL);
    }
}
